import { createApp } from 'vue'
import './public-path'
import App from './App.vue'
let app = null
// 将渲染操作放入 mount 函数
function mount () {
  app = createApp(App).mount('#app')
  console.log('微应用child-vue渲染了')
}

// 将卸载操作放入 unmount 函数
function unmount () {
  app.unmount && app.unmount()
  app = null
  console.log('微应用child-vue3卸载了')
}

// 微前端环境下，注册mount和unmount方法
if (window.__MICRO_APP_ENVIRONMENT__) {
  window[`micro-app-${window.__MICRO_APP_NAME__}`] = { mount, unmount }
} else {
  // 非微前端环境直接渲染
  mount()
}
